#!/bin/env python
# -*- coding: utf-8 -*-


"""
File Name: write_hbase.py
Author: morre <morre@vip.qq.com>
Create Time: 2022/12/31 16:58:47
Brief:
"""

import json
from hbase_client import HbaseClient

hbase_conf = None
with open("hbase.conf", "r", encoding="utf8") as conf_fp:
    hbase_conf = json.load(conf_fp)

client_obj = HbaseClient(
    zkquorum=hbase_conf["zkquorum"], zk_root_path=hbase_conf["zk_root_path"],
    init_socket_pool_size=1, establish_connection_timeout=60,
    missing_znode_retries=3, rpc_socket_timeout=30)
client_obj.open()
for i in range(10):
    idx = json.dumps(i)
    ret = client_obj.put(
        b"test:test_table", idx.encode(),
        {b"data": {b"url": b"url" + idx.encode()}},
        auto_flush=True)
    print("\t".join([idx, json.dumps(ret)]))
